package com.xiaoxiao.springbootstudy.controller;

import com.xiaoxiao.springbootstudy.pojo.Order;
import com.xiaoxiao.springbootstudy.pojo.vo.CountResult;
import com.xiaoxiao.springbootstudy.pojo.vo.MonthOrder;
import com.xiaoxiao.springbootstudy.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/listOrder")
    public Map<String, Object> listOrders(@RequestBody Order order) {
        return orderService.queryOrderListService(order.getPageNum(), order.getPageSize(), order);
    }

    @GetMapping("/getYearMonthOrder")
    public List<MonthOrder> getYearMonthOrder() {
        return orderService.queryYearMonthOrderService();
    }

    @GetMapping("/getSellNum")
    public List <CountResult> getSellNum(@RequestParam String year) {
        return orderService.querySellNumService(year);
    }
}
